#ifndef LINK_H
#define LINK_H

#include <QUrl>
#include "httpclient.h"
#include <QTime>
#include <QtXml>
#include <QNetworkProxy>
#include "proxy/proxydesc.h"

class HttpClient;

class Link:public QObject{
    Q_OBJECT

    static int count;
    int _index;
    int _progress;
    ProxyDesc* _proxy;
    QUrl _url;
    HttpClient* _client;
    int _state;
    int _speed;
    QTime speedTimer;
    qint64 speedCounter;
public:

    static const int FREE=0;
    static const int INUSE=1;
    static const int DOWNLOADING_FILE=2;
    static const int WAIT=3;
    static const int FINISHED=4;

    static const int ERR_DELETED = 6;
    static const int ERR_UNKNOWN_PAGE = 7;
    static const int ERR_SOCKET_ERROR = 8;
    static const int ERR_UNKNOWN_PROVIDER = 9;

    static const int INFO_SHORT_DELAY = 20;
    static const int INFO_CAPTCHA = 21;
    static const int INFO_CAPTCHA_SOLVED = 21;

    int state();
    void setState(int);
    HttpClient* client();
    void setClient(HttpClient*);
    QUrl url();
    void setUrl(QUrl);
    ProxyDesc* proxy();
    void setProxy(ProxyDesc*);
    int progress();
    QString hostService();
    Link();
    QString fileDownloadName();
    QDomElement xmlDesc(QDomDocument*);
    bool changed;
public slots:
    void downloadProgress(qint64 prog,qint64 tot);
};
#endif // LINK_H
